package com.wn.class30.service.impl;

import com.wn.class30.entity.ProductImgDetail;
import com.wn.class30.entity.ProductImgDetailExample;
import com.wn.class30.mapper.ProductImgDetailDao;
import com.wn.class30.service.ProductImgDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProductImgDetailServiceImpl implements ProductImgDetailService {
    @Resource
    private ProductImgDetailDao productImgDetailDao;
    @Override
    public List<ProductImgDetail> selectProductImgDetailsByProductId(Integer productId) throws Exception {
        ProductImgDetailExample productImgDetailExample = new ProductImgDetailExample();
        ProductImgDetailExample.Criteria criteria = productImgDetailExample.createCriteria();
        criteria.andProductIdEqualTo(productId);
        return productImgDetailDao.selectByExample(productImgDetailExample);
    }

    @Override
    public void insertProductImgDetail(ProductImgDetail productImgDetail) throws Exception {
        productImgDetailDao.insert(productImgDetail);
    }

    @Override
    public void deleteProductImgDetailByProductId(Integer productId) throws Exception {
        ProductImgDetailExample productImgDetailExample = new ProductImgDetailExample();
        ProductImgDetailExample.Criteria criteria = productImgDetailExample.createCriteria();
        criteria.andProductIdEqualTo(productId);
        productImgDetailDao.deleteByExample(productImgDetailExample);
    }
}
